class Scdoc < Formula
  desc "Small man page generator"
  homepage "https://git.sr.ht/~sircmpwn/scdoc/"
  url "https://git.sr.ht/~sircmpwn/scdoc/archive/1.9.6.tar.gz"
  sha256 "89a5f2294b4b72ee1d20b8a478d16bee1f96b6202bfeedb6df76c27881ed5928"

  bottle do
    cellar :any_skip_relocation
    sha256 "6084303301f6e5c021c2231c8302d8dab2473d51c2cf07dc370860b2d9f47ea5" => :mojave
    sha256 "85aae7199b6347cbd5afa97e7a9e0101407304a88faa2b0ca72a4e601bc8014d" => :high_sierra
    sha256 "a36c9b25ca2057ebdff52aa0332a6174a0f1870cd02ab5cc07189f80a6ca9b9a" => :sierra
  end

  def install
    # scdoc sets by default LDFLAGS=-static which doesn't work on macos(x)
    system "make", "LDFLAGS=", "PREFIX=#{prefix}"
    system "make", "install", "PREFIX=#{prefix}"
  end

  test do
    preamble = <<~'EOF'
      .\" Generated by scdoc 1.9.6
      .ie \n(.g .ds Aq \(aq
      .el       .ds Aq '
      .nh
      .ad l
      .\" Begin generated content:
    EOF
    assert_equal preamble, shell_output("#{bin}/scdoc </dev/null")
  end
end
